Skip to content

Use a socketpair for TriggerFd only on QNX - #32

Merged
dallison merged 5 commits into
mainfrom
qnx_pipes
Nov 16, 2026
Merged

dallison merged 5 commits into
mainfrom
qnx_pipes

Conversation

@dallison

@dallison dallison commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • On QNX, TriggerFd uses a Unix domain socketpair. QNX pipes go through a single-threaded pipe service. Linux stays on eventfd. macOS and other POSIX systems stay on a pipe.
  • TOOLBELT_TRIGGERFD_SIGNAL_MECHANISM overrides that default: TOOLBELT_TRIGGERFD_EVENTFD, TOOLBELT_TRIGGERFD_PIPE, or TOOLBELT_TRIGGERFD_SOCKETPAIR.
  • Bazel: --//toolbelt:trigger_mechanism=default|eventfd|pipe|socketpair. default leaves the macro unset so the header keeps the platform choice.

Test plan

  • //toolbelt:triggerfd_test passes with the default and with --//toolbelt:trigger_mechanism=pipe and socketpair on macOS.
  • --//toolbelt:trigger_mechanism=eventfd fails to compile on macOS with the Linux-only error.
  • aquery shows no TOOLBELT_TRIGGERFD_SIGNAL_MECHANISM define for default, and the pipe or socketpair define otherwise.
  • QNX build of the socketpair default.

TriggerFd used a pipe on every platform without eventfd. On QNX, pipes
are served by the single-threaded pipe resource manager, which makes
them slow under load. A socketpair is pollable, nonblocking, and can be
passed over SCM_RIGHTS, so it is a drop-in replacement for the pipe on
macOS, QNX, and other POSIX systems. Linux keeps using eventfd.

Add triggerfd_test covering create, trigger/clear, repeated triggers,
non-blocking behaviour when the buffer is full, and move semantics.
QNX pipes go through a single-threaded pipe service. On macOS a socketpair was slower than a pipe, especially when a publish wakes another thread, and its read end always reports POLLOUT. Linux stays on eventfd and other POSIX systems stay on a pipe.
@dallison dallison changed the title Use a Unix domain socketpair for TriggerFd on non-Linux POSIX Use a socketpair for TriggerFd only on QNX Nov 15, 2026
The platform default stays eventfd on Linux, a socketpair on QNX, and a pipe elsewhere. --//toolbelt:trigger_mechanism selects eventfd, pipe, or socketpair when a build needs a different way to wake a waiting subscriber.
Ubuntu 26.04's GCC still emits TSan function entry and exit hooks in
functions that switch coroutine stacks. The hook then writes off the
shadow stack and pipe_test and sockets_test die in gtest teardown.
Apply the dallison/co fix from c2cbd0f onto the pinned 3.4.1 commit.
@dallison
dallison merged commit 543ef9a into main Nov 16, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant